package com.yxw.live_vod_backend_boot.controller;

import com.yxw.live_vod_backend_boot.dto.BillingQueryDTO;
import com.yxw.live_vod_backend_boot.dto.BillingSetupDTO;
import com.yxw.live_vod_backend_boot.service.BillingSetupService;
import com.yxw.live_vod_backend_boot.vo.BillingSetupVO;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 计费设置管理 Controller控制层
 *
 * @author xiexuxin
 * @date 2023-11-30
 */
@RestController
@Api(value = "计费设置管理", tags = "计费设置管理")
@Slf4j
@RequestMapping("/api/billing_setup")
public class BillingSetupController {

    @Autowired
    private BillingSetupService billingSetupService;

    @ApiOperation("设置直播扣费规则")
    @PostMapping("setup_fee_deduct_ratio")
    public BaseResult setupFeeDeductRatio(@RequestBody @Validated BillingSetupDTO feeDeductDTO) {
        billingSetupService.setupFeeDeductRatio(feeDeductDTO);
        return BaseResult.success("设置成功");
    }

    @ApiOperation("设置视频币兑换规则")
    @PostMapping("setup_video_coin_ratio")
    public BaseResult setupVideoCoinRatio(@RequestParam("videoCoin") Integer videoCoin) {
        billingSetupService.setupVideoCoinRatio(videoCoin);
        return BaseResult.success("设置成功");
    }

    @ApiOperation("设置点播空间大小")
    @PostMapping("setup_on_demand_space_size")
    public BaseResult setupOnDemandSpaceSize(@RequestParam("onDemandSpace") Integer onDemandSpace) {
        billingSetupService.setupOnDemandSpaceSize(onDemandSpace);
        return BaseResult.success("设置成功");
    }

    @ApiOperation("获取计费设置列表")
    @PostMapping("get_billing_setup_list")
    public BaseResult<PageVO<BillingSetupVO>> getBillingSetupList(@RequestBody @Validated BillingQueryDTO dto) {
        PageVO<BillingSetupVO> pageVO = billingSetupService.getBillingSetupList(dto);
        return ResultHelper.fillWithSuccess(pageVO);
    }

}
